#ifndef VSSKELECTON_H
#define VSSKELECTON_H
#include "VSNode.h"
#include "VSGeometry.h"
namespace VSEngine2
{
	class VSBoneNode;
	typedef VSPointer<VSBoneNode> VSBoneNodePtr;
	class VSStream;
	class VSGRAPHIC_API VSSkelecton : public VSNode
	{
		//PRIORITY
		
		//RTTI
		DECLARE_RTTI;
		DECLARE_INITIAL
	public:
		VSSkelecton();
		virtual ~VSSkelecton();
		virtual unsigned int GetST(){return ST_SKELECTON;}
	public:

		virtual bool Register(VSStream & rStream)const;
		
		virtual unsigned int DiskUse()const;

		virtual bool Save(VSStream & rStream,unsigned int &iSaveUse)const;
		virtual bool Load(VSStream & rStream,unsigned int &iSaveUse);
		virtual bool Link(VSStream & rStream);
	protected:
		VSArray<VSBoneNode *> m_pBoneArray;

		void LinkBoneArray();
		virtual void UpdateNodeAll(double dAppTime);
		virtual void ComputeNodeVisibleSet(VSCuller & Culler,bool bNoCull,double dAppTime);

		static float ms_fBoneAxisLength;
		void Draw(VSCamera * pCamera);
	public:
		virtual bool Clone(const VSObject *pObject,unsigned int uiType);

	public:
		friend class VSSkelectonMeshNode;

		void CreateBoneOffSetAndOriginMatrix();
		
		

		unsigned int GetBoneNum()const;
		VSBoneNode *GetBoneNode(const VSUsedName & Name)const;
		VSBoneNode * GetBoneNode(unsigned int i)const;

		int GetBoneIndex(const VSUsedName &Name)const;
		bool m_bIsDrawSkelecton;
	

		virtual void UpDateView(VSCuller & Culler,double dAppTime);
	};
	DECLARE_Ptr(VSSkelecton);
	VSTYPE_MARCO(VSSkelecton);
}
#endif